import { defineStore } from 'pinia'
import type { ICATALOG } from '@/types'

export const useCatalogStore = defineStore(
  'catalogStore',
  () => {
    const catalog = ref<ICATALOG>({} as ICATALOG)
    const setCatalog = (item: ICATALOG) => {
      catalog.value = item
    }
    const clearCatalog = () => {
      catalog.value = {} as ICATALOG
    }
    return { catalog, setCatalog, clearCatalog }
  },
  {
    persist: {
      key: 'currentCatalog',
      storage: sessionStorage
    }
  }
)
